package com.lh.java.basic.datatype;

public class HighArray {
	protected long [] arry;
	protected int nElems;
	
	public HighArray(int pacity){
		arry = new long[pacity];
		nElems = 0;
	}
	
	public boolean find(long searchKey){
		int j;
		for(j=0;j<nElems;j++){
			if(searchKey==arry[j]){
				break;
			}			
		}
		if(j==nElems){
			return false;
		}else {
			return true;
		}
	}
	
	public void insert(long value){
		arry[nElems] = value;
		nElems++;		
	}
	
	public boolean delete(long value){
		int j;
		for(j=0;j<nElems;j++){
			if(value==arry[j]){
				break;
			}			
		}
		if(j==nElems){
			return false;
		}else {
			for(int k=j;k<nElems;k++){
				arry[k]=arry[k+1];
			}
			nElems--;
			return true;
		}
		
	}
	
	public void display(){
		for(int j=0;j<nElems;j++){
			System.out.print(arry[j]+" ");			
		}
		System.out.println();
	}
	


}
